package jtk.project4.fleet.screen.Insurance;

import java.awt.FlowLayout;
import java.text.SimpleDateFormat;

import jtk.project4.fleet.field.EquipmentInsurancePolicyInformationField;

import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.FormView;
import nl.coderight.jazz.form.FormLayout.Align;
import nl.coderight.jazz.form.control.CalendarControl;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.MemoField;
import nl.coderight.jazz.form.field.NumberField;
import nl.coderight.jazz.form.field.SelectField;
import nl.coderight.jazz.form.field.TextField;
import nl.coderight.jazz.form.field.button.PushButton;

	public class EquipmentInsuranceView extends FormView {
		private SelectField companyField;
		private MemoField companyInfoField;
		private TextField policyField;
		private CalendarControl startDateField;
		private CalendarControl endDateField;
		private NumberField paymentField;
		private NumberField deductibleField;
		private TextField notesField;
		
		
			
				
			@Override
			protected void init() {
				//createAction();
				//createFields();
				createLayout();		
			}	
			
			private void createAction() {
				/*submitAction = new SubmitAction();
				cancelAction = new CancelAction();
				// enable submit button when form is changed
				setOnChangeAction(submitAction);
			*/}
			
			/*
			private void createFields(){
				policyField = new TextField("Policy#", 15);
				
				companyField = new SelectField("Equipments","Company");
				companyInfoField = new MemoField("Company Info");
				companyInfoField.setRows(4);
				companyInfoField.setEditable(false);
				companyField.setPreferredSize(policyField.getPreferredSize());
				companyInfoField.setPreferredSize(policyField.getPreferredSize());
				
				
				startDateField = new CalendarControl("Start Date", 0);
				startDateField.setFormat(new SimpleDateFormat(translate("MM/dd/yyyy")));
				startDateField.showYearSpinner(true);

				endDateField = new CalendarControl("End Date", 0);
				endDateField.setFormat(new SimpleDateFormat(translate("MM/dd/yyyy")));
				endDateField.showYearSpinner(true);		
				
				startDateField.setPreferredSize(policyField.getPreferredSize());
				endDateField.setPreferredSize(policyField.getPreferredSize());
				
				paymentField = new NumberField("Payment",10);
				paymentField.setRequired(true);
				
				deductibleField = new NumberField("Deductible",10);
				deductibleField.setRequired(true);
				
				notesField = new MemoField("Notes");
				notesField.setEditable(true);
				notesField.setRows(1);
				
				submitButton = new PushButton("submit");
				cancelButton = new PushButton("cancel");
					
			}
			*/
			
			private void createLayout() {
				//setHeader(createHeader());
				addField(createForm());			
			}
			
			private GroupControl createInsuranceForm(){
				GroupControl form = new GroupControl();
				form.setLayout(new FormLayout())
				.addField(new EquipmentInsurancePolicyInformationField("insurance"))
				/*
				.addLabel("Company")	.addField(companyField)
				.addRow()
				.addLabel("")			.addField(notesField)
				.addRow()
				.addLabel("Policy#")	.addField(policyField)
				.addLabel("Payment")	.addField(paymentField)
				.addRow()
				.addLabel("Start Date")	.addField(startDateField)
				.addLabel("Deductible")	.addField(deductibleField)
				.addRow()
				.addLabel("End Date")	.addField(endDateField)
				.addLabel("Notes")		.addField(notesField)
				*/
				;
				return form;
			}
			
			/*private FormHeader createHeader() {
				formHeader = new FormHeader();
				formHeader.setTitle("equipment.header.form");
				return formHeader;
			}*/
			
			private GroupControl createForm() {
				GroupControl form = new GroupControl();
				//form.addField(selectButton, NORTH);
				form.addField(createInsuranceForm(), NORTH);
				//form.addField(createButtons(), SOUTH);		
				return form;
			}
			/*
			private GroupControl createButtons() {
				GroupControl buttons = new GroupControl();
				buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
				buttons.addField(submitButton);
				buttons.addField(cancelButton);
				return buttons;
			}	
			*/
	
	}
